package com.og.backingbean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.NotEmpty;

/**
 * @author Renaud DIANA
 *
 */
@Entity
@NamedQueries({@NamedQuery(name = "Bug.findAll", query = "SELECT b FROM Bug b ORDER BY b.idBug ASC")})
public class Bug implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int idBug;
	@NotNull
	@NotEmpty
	@Column(nullable = false)
	private String name;
	@NotNull
	@NotEmpty
	@Size(max = 100)
	@Column(nullable = false, length = 100)
	private String type;
	private String comments;
	@OneToMany(mappedBy = "bug", cascade = CascadeType.ALL)
	@JoinColumn(name = "bug_idbug")
	private List<Ticket> listTicket;
	@OneToMany(mappedBy = "bug", cascade = CascadeType.ALL)
	@JoinColumn(name = "bug_idbug")
	private List<Solution> listSolution;
	
	/**
	 * Default constructor
	 */
	public Bug() {
		// TODO Auto-generated constructor stub
	}

	public int getIdBug() {
		return idBug;
	}

	public void setIdBug(int idBug) {
		this.idBug = idBug;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

}
